package org.ws.task.zookeeper;

import org.apache.curator.utils.ZKPaths;

/**
 * Paths
 */
public abstract class NodePaths {
    private static final String ROOT_PATH = "ws-task";

    private static final String LEADER_PATH = "leader";

    private static final String LEADER_DATA_PATH = "leader-data";

    private static final String WORKERS_PATH = "workers";

    private static final String WORKERS_NODE_PATH = "node";

    private static final String TASK_CONFIG_PATH = "tasks";

    private NodePaths() {

    }

    public static String getLeaderPath(String namespace){
        return markPath(namespace,LEADER_PATH);
    }

    public static String getLeaderDataPath(String namespace){
        return markPath(namespace,LEADER_DATA_PATH);
    }

    public static String getWorkersPath(String namespace){
        return markPath(namespace,WORKERS_PATH);
    }

    public static String getWorkersNodePath(String namespace){
        return markPath(namespace,WORKERS_PATH,WORKERS_NODE_PATH);
    }

    private static String markPath(String child,String... rest){
        return ZKPaths.makePath(ROOT_PATH,child,rest);
    }
}
